import QtQuick 2.0


Image {
    id:container
    signal clicked
    signal horvered

    property alias normalSource:container.source


    MouseArea{
        anchors.fill: parent

        hoverEnabled: true

        onPressed: {
            container.state = "pressed"
        }

        onReleased: {
            if(mouse.containsMouse)
                container.state = "hovered"
        }

        onEntered: {
            if(container.state !== "clicked"){
                container.state = "hovered"
                container.horvered()
            }
        }

        onExited: {
            if(container.state !== "clicked")
                container.state = "normal"
        }

        onClicked: {
            emit:container.clicked()
        }
    }

    states: [
        State {
            name: "hovered"
            PropertyChanges {
                target: container
                scale:1.4
            }
        },
        State {
            name: "normal"
            PropertyChanges {
                target: container
                scale:1.0
            }
        },
        State {
            name: "pressed"
            PropertyChanges {
                target: container
                scale:1.4
            }
        } ,
        State {
            name: "clicked"
            PropertyChanges {
                target: container
                scale:1.0
            }
        }

    ]
}
